<template>

  <div>
    <el-table v-loading.body="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
      <el-table-column prop="id" label="id" min-width="30" align="center" ></el-table-column>
      <el-table-column prop="storageName" label="一级仓库名称" min-width="120" align="center" ></el-table-column>
      <el-table-column prop="roomName" label="二级仓库名称" min-width="120" align="center" ></el-table-column>
      <el-table-column prop="alarmStatus" label="是否通知客服" min-width="120" align="center" >
        <template slot-scope="scope">
          {{ scope.row.alarmStatus | statusName  }}
        </template>
      </el-table-column>
      <el-table-column prop="alarmName" label="客服负责人" min-width="120" align="center" ></el-table-column>
      <el-table-column prop="createTime" label="创建时间" min-width="120" align="center" ></el-table-column>
      <el-table-column align="center" label="操作" width="120">
        <template slot-scope="scope">
          <router-link :to="'/operation/detail?id='+scope.row.id">
            <el-button type="text" size="small" icon="el-icon-edit">详情</el-button>
          </router-link>
          <router-link :to="'/operation/edit?id=' +scope.row.id">
            <el-button type="text" size="small" icon="el-icon-edit">编辑</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination
        :current-page="listQuery.page"
        :page-sizes="[10,20,30, 50]"
        :page-size="listQuery.limit"
        :total="total"
        background
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"/>
    </div>

  </div>
</template>

<script>
import {roomAlarmList , roomAlarmDetail , updateRoomAlarm , deleteRoomAlarm } from "../../api/roomalarm";

export default {
  name: "list",
  filters: {
    statusName(alarmStatus) {
      if (alarmStatus==1) {
        return '是';
      }else{
        return '否'
      }
    }
  },
  data() {
    return {
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      roomAlarmList(this.listQuery).then(response => {
        this.list = response.data.data
        this.total = response.data.count
        this.listLoading = false
      })
    },
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.listQuery.page = 1
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.getList()
    }
  }
}
</script>

<style scoped>

</style>
